package com.baidu.bos.web.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.baidu.bos.domain.Workordermanage;
import com.baidu.bos.service.IWorkordermanageService;
import com.baidu.bos.web.action.base.BaseAction;
import com.opensymphony.xwork2.ActionContext;

@Controller
@Scope("prototype")
public class WorkordermanageAction extends BaseAction<Workordermanage>{
	/**
	 * 
	 */
	private static final long serialVersionUID = 3394722022769946661L;
	@Resource
	private IWorkordermanageService workordermanageService;
	
	public String save(){
		String flag = "1";
		try {
			workordermanageService.save(model);
		} catch (Exception e) {
			e.printStackTrace();
			flag = "0";
		}
		this.writeObject2Json(flag);
		return NONE;
	}
	
	//分页查询
	public String pageQuery(){
		workordermanageService.pageQuery(pageBean);
		this.writeObject2Json(pageBean);
		return NONE;
	}
	
	//查询未启动的工作单数据
	public String list(){
		List<Workordermanage> list = workordermanageService.findListNotStart();
		ActionContext.getContext().getValueStack().set("list", list);
		return "list";
	}
	
	//启动配送流程
	public String start(){
		workordermanageService.start(model.getId());
		return "toList";
	}
}
